/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "subramas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Subramas.findAll", query = "SELECT s FROM Subramas s"),
    @NamedQuery(name = "Subramas.findByIdSubrama", query = "SELECT s FROM Subramas s WHERE s.idSubrama = :idSubrama"),
    @NamedQuery(name = "Subramas.findBySubrama", query = "SELECT s FROM Subramas s WHERE s.subrama = :subrama")})
public class Subramas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Subrama")
    private Integer idSubrama;
    @Size(max = 50)
    @Column(name = "Subrama")
    private String subrama;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSubrama")
    private Collection<Subcategorias> subcategoriasCollection;
    @JoinColumn(name = "id_Rama", referencedColumnName = "id_Rama")
    @ManyToOne(optional = false)
    private Ramas idRama;
    @OneToMany(mappedBy = "idSubrama")
    private Collection<Productos> productosCollection;

    public Subramas() {
    }

    public Subramas(Integer idSubrama) {
        this.idSubrama = idSubrama;
    }

    public Integer getIdSubrama() {
        return idSubrama;
    }

    public void setIdSubrama(Integer idSubrama) {
        this.idSubrama = idSubrama;
    }

    public String getSubrama() {
        return subrama;
    }

    public void setSubrama(String subrama) {
        this.subrama = subrama;
    }

    @XmlTransient
    public Collection<Subcategorias> getSubcategoriasCollection() {
        return subcategoriasCollection;
    }

    public void setSubcategoriasCollection(Collection<Subcategorias> subcategoriasCollection) {
        this.subcategoriasCollection = subcategoriasCollection;
    }

    public Ramas getIdRama() {
        return idRama;
    }

    public void setIdRama(Ramas idRama) {
        this.idRama = idRama;
    }

    @XmlTransient
    public Collection<Productos> getProductosCollection() {
        return productosCollection;
    }

    public void setProductosCollection(Collection<Productos> productosCollection) {
        this.productosCollection = productosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSubrama != null ? idSubrama.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Subramas)) {
            return false;
        }
        Subramas other = (Subramas) object;
        if ((this.idSubrama == null && other.idSubrama != null) || (this.idSubrama != null && !this.idSubrama.equals(other.idSubrama))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Subramas[ idSubrama=" + idSubrama + " ]";
    }
    
}
